
package com.yunfei.api.cardSend;

import com.yunfei.api.cardSend.param.CardSendParam;
import com.yunfei.api.cardSend.result.CardSendResultBo;
import com.yunfei.api.user.contants.MingPianZhuanFaContants;
import com.yunfei.bo.result.ResultModel;
import com.yunfei.enums.CardSendResultStatus;
import com.yunfei.enums.ResultStatus;
import com.yunfei.fegin.RedisFeignService;
import com.yunfei.mapper.aiiidb.CardMapper;
import com.yunfei.mapper.aiiidb.GetStatusMapper;
import com.yunfei.mapper.aiiidb.TPersonalUserMapper;
import com.yunfei.ribbon.RedisServiceRibbon;
import com.yunfei.service.RedisService;
import com.yunfei.service.ValidMobileAndCodeService;
import com.yunfei.utils.string.StringUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.env.Environment;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

/**
 * @Description: 用户中心
 * @Author: zhengyunfei
 * @Date: 2018/6/15
 * @time:11:26
 */
@SuppressWarnings("ALL")
@RestController
@RequestMapping("/cardSend")
@Api(value = MingPianZhuanFaContants.NAMESPACE,tags =  MingPianZhuanFaContants.NAMESPACE )
public class MingPianZhuanFaApiController {
    @Autowired
    private TPersonalUserMapper tPersonalUserMapper;
    @Autowired
    private GetStatusMapper getStatusMapper;
    @Autowired
    private RedisFeignService redisFeignService;
    @Autowired
    private RedisService redisService;
    @Autowired
    private RedisServiceRibbon redisServiceRibbon;
    @Autowired
    private ValidMobileAndCodeService validMobileAndCodeService;
    @Autowired
    private Environment env;
    @Autowired
    private CardMapper cardMapper;

    @PostMapping(value="/get")
    @ApiOperation(value =MingPianZhuanFaContants.GET,notes = MingPianZhuanFaContants.GET,position = 1,response = CardSendResultBo.class)
    @ResponseBody
    public Object get(CardSendParam param){
        ResultModel resultModel=new ResultModel();
        Map<String,Object> queryMap=new HashMap<>();
        String userId=param.getUserId();
        if(StringUtil.isNullOrEmpty(userId)){
            resultModel.setCode(CardSendResultStatus.USERID_NOTNULL.getCode());
            resultModel.setMessage(CardSendResultStatus.USERID_NOTNULL.getMessage());
            return resultModel;
        }
        queryMap.put("userId",userId);
        CardSendResultBo cardSendResultBo=cardMapper.get(queryMap);
        resultModel.setCode(ResultStatus.SUCCESS.getCode());
        resultModel.setMessage(ResultStatus.SUCCESS.getMessage());
        if(!StringUtil.isNullOrEmpty(cardSendResultBo)){
            resultModel.setData(cardSendResultBo);
        }else{
            resultModel.setCode(CardSendResultStatus.NOT_EXSITS_LICAISHI.getCode());
            resultModel.setMessage(CardSendResultStatus.NOT_EXSITS_LICAISHI.getMessage());
            resultModel.setData(CardSendResultStatus.OPER_SUCCESS.getMessage());
        }

        return resultModel;

    }

}
